package com.evry.spring3sandbox.service;

import java.math.BigDecimal;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.format.annotation.NumberFormat;
import org.springframework.format.annotation.NumberFormat.Style;

public class PriceIncrease {

    /** Logger for this class and subclasses */
    protected final Log logger = LogFactory.getLog(getClass());
    
    @NotNull
    @NumberFormat(style = Style.PERCENT, pattern = "#,###.###")
    @Min(value=0)
    @Max(value=50, message = "Price cannot be higher than 50%")
    private BigDecimal percentage;

    public void setPercentage(BigDecimal i) {
        percentage = i;
        logger.info("Percentage set to " + i);
    }

    public BigDecimal getPercentage() {
        return percentage;
    }

}